home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "PSETUP.DLL DEMO"
- ClientHeight = 1575
- ClientLeft = 345
- ClientTop = 1935
- ClientWidth = 7140
- Height = 2265
- Left = 285
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 1575
- ScaleWidth = 7140
- Top = 1305
- Width = 7260
- Begin Menu FileMNU
- Caption = "&File"
- Begin Menu PSetupMNU
- Caption = "Printer &Setup"
- End
- Begin Menu ExitMNU
- Caption = "E&xit"
- End
- End
- ' We use GetProfileString to retrieve the current Printer Driver's Name and output port (e.g. LPT1:)
- Declare Function GetProfileString Lib "KERNEL" (ByVal App$, ByVal Keyname$, ByVal DefaultVal$, ByVal RetBuf$, ByVal Size%) As Integer
- ' PSETUP.DLL has only one function: DoPrinterSetup which invokes the Windows 3.0 standard
- ' Printer Setup Dialog. It expects three parameters: the calling form's hWnd handle,
- ' the name of the printer driver, and the ouptut port. The function returns true if the
- ' Printer Setup dialog was implemented and false if it wasn't, but in most cases you won't
- ' need to check the return value.
- Declare Function DoPrinterSetup Lib "PSETUP.DLL" (ByVal hwnd%, ByVal DriverName$, ByVal PortName$) As Integer
- Const true = -1
- Const false = 0
- Sub ExitMNU_Click ()
- ' Bye
- End Sub
- Sub PSetupMNU_Click ()
- ' Prepare a long enough ASCIIZ Return Buffer
- RetStr$ = String$(256, 0)
- RetStrSize% = Len(RetStr$)
- ' The info we need is in the [windows] section, under "device"
- x% = GetProfileString("windows", "device", "", RetStr$, RetStrSize%)
- ' Parse the RetStr$ to the components that interest us.
- i% = InStr(RetStr$, ",")
- If i% > 0 Then
- a$ = Left$(RetStr$, i% - 1)
- b$ = Right$(RetStr$, Len(RetStr$) - i%)
- j% = InStr(b$, ",")
- If j% > 0 Then
- DriverName$ = Left$(b$, j% - 1)
- PortName$ = Right$(b$, Len(b$) - j%)
- End If
- End If
- ' Call DoPrinterSetup sending it the Form's handle, the printer driver name, and port.
- ' Note: Do not add the extension "drv" to DriverName$. PSETUP.DLL does it for you.
- r% = DoPrinterSetup(Form1.hwnd, DriverName$, PortName$)
- If Not r% Then MsgBox "Can't run Printer Setup" + Chr$(13) + Chr$(10) + "Please check your installation", 64, "Printer Setup"
- End Sub
-